﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DVO;

public partial class ReviewDocument : System.Web.UI.Page
{
    public string username = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!string.IsNullOrEmpty(Page.User.Identity.Name))
        {
            username = Page.User.Identity.Name;

            if (IsPostBack == false)
            {
                LoadData();
                //if (username != "test")
                //{
                //    grid.Columns[6].Visible = false;
                //    grid.Columns[5].Visible = true;
                //}
                //if (username != "Review1" || username != "Review2" || username != "Review3")
                //{
                //    grid.Columns[5].Visible = false;
                //    grid.Columns[6].Visible = true;
                //}
                //if (username == "nhanvien")
                //{
                //    grid.Columns[5].Visible = false;
                //    grid.Columns[6].Visible = false;
                //}
            }
        }
        else
        {
            Response.Redirect("Login.aspx");
        }
    }
    #region "LoadData"
    private void LoadData()
    {
        string Id = txtDocId.Text.Trim();
        string documentname = txtDocName.Text.Trim();
        string author = ddlAuthor.SelectedValue;
        string usename = Page.User.Identity.Name;
        BLL_Document ObjBLL = new BLL_Document();
        List<ins_Document_SearchCheckResult> ObjList = new List<ins_Document_SearchCheckResult>();
        ObjList = ObjBLL.Document_SearchAgree(Id,documentname,author,usename).ToList(); 
        grid.DataSource = ObjList;
        grid.DataBind();

    }
    #endregion

    public string GetStatus(string Status)
    {
        if (Status == "0")
            return "Chờ kiểm duyệt";
        else if (Status == "1")
            return "Đã duyệt";
        else if (Status == "2")
            return "Chờ phê duyệt";
        else if (Status == "3")
            return "Chỉnh sửa";
        return "";
    }
    protected void grid_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        grid.PageIndex = e.NewPageIndex;
        LoadData();
    }
}